//
//  LGtools.h
//
//  Created by guomianxiang on 15/8/17.
//  Copyright © 2015年 guomianxiang. All rights reserved.
//

///////////////////////////////////////////
#pragma mark - 屏幕宽高
#define kScreen_H [UIScreen mainScreen].bounds.size.height
#define kScreen_W [UIScreen mainScreen].bounds.size.width

///////////////////////////////////////////
#pragma mark - UIColor
/**16进制颜色
 */
#define kColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define kColorA(r, g, b, a)  [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)/255.0]

#define kColor(r, g, b)  kColorA((r), (g), (b), 255)

#define kRandomColor  LGColor(arc4random_uniform(255), arc4random_uniform(255), arc4random_uniform(255))

#define kGrayColor(v)  kColor((v), (v), (v))
///////////////////////////////////////////
#pragma mark - 日志
#ifdef DEBUG
#define kLog(...)  NSLog(__VA_ARGS__);
#define kLogFunc   NSLog(@"%s",__func__);

#define kLogFreme(frame)  NSLog(@"%@",NSStringFromCGRect(frame))

#else
#define kLog(...)
#endif

///////////////////////////////////////////
#pragma mark - 单例

#define singleH(name) +(instancetype)share##name;

#if __has_feature(objc_arc)

#define singleM(name) static id _instance;\
+(instancetype)allocWithZone:(struct _NSZone *)zone\
{\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
_instance = [super allocWithZone:zone];\
});\
return _instance;\
}\
\
+(instancetype)share##name\
{\
return [[self alloc]init];\
}\
-(id)copyWithZone:(NSZone *)zone\
{\
return _instance;\
}\
\
-(id)mutableCopyWithZone:(NSZone *)zone\
{\
return _instance;\
}


#else
#define singleM static id _instance;\
+(instancetype)allocWithZone:(struct _NSZone *)zone\
{\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
_instance = [super allocWithZone:zone];\
});\
return _instance;\
}\
\
+(instancetype)shareTools\
{\
return [[self alloc]init];\
}\
-(id)copyWithZone:(NSZone *)zone\
{\
return _instance;\
}\
\
-(id)mutableCopyWithZone:(NSZone *)zone\
{\
return _instance;\
}\
-(oneway void)release\
{\
}\
\
-(instancetype)retain\
{\
return _instance;\
}\
\
-(NSUInteger)retainCount\
{\
return MAXFLOAT;\
}
#endif
///////////////////////////////////////////
